#ifndef prs_odbNodes_H
#define prs_odbNodes_H

#include "prs_Attr.h"
#include "odb.h"

namespace prs
{

extern const char *nodeType_Database;
extern const char *nodeType_Table;
extern const char *nodeType_String;
extern const char *nodeType_Ref;
extern const char *nodeType_RefG;
extern const char *nodeType_Datetime;
extern const char *nodeType_Integer;
extern const char *nodeType_Double;

extern const char *attrName_Size;
extern const char *attrName_ToTable;

struct TOdbParams{
	TOdbParams( odb::TFieldInsert &i, odb::TFieldDelete &d
		      , svl::TString &root, svl::TString &mname, bool insert)
			  : I(i), D(d), Root(root), mName(mname), Insert(insert) {};
	
	odb::TFieldInsert &I;
	odb::TFieldDelete &D;
	svl::TString	  Path;
	svl::TString	  &Root;
	svl::TString	  &mName;
	bool Insert;
};

struct TNodeOdb : public TAttrNode {
  //
	TNodeOdb(): id(this),OldChildren(this) {}
	virtual TNode *New(){ return new TNodeOdb; }
	virtual void odbSync( TOdbParams Params ){};
	void odbSyncDef( TOdbParams Params ){
		TNodeOdb* Child;
		for( int i = 0; i < OldChildren.Array.Count(); i++ ){
			Child = dynamic_cast<TNodeOdb*>( &OldChildren.Array.Get(i) );
			if( Child )
				Child->odbSync( Params );
		}
	}
	virtual TAttrNodeTypeBase* GetType(){ return NULL; };
 	
	TAttrId id;
  TAttrNodeArray<attrName_OldChildren,TNodeArray> OldChildren;
};

}
#endif

